import { createStore, applyMiddleware, combineReducers } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import reducer from './reducer'
import listReducer from '../components/List/redux/reducer'
import thunk from 'redux-thunk'

// 协作开发时,一定会有多个reducer,但是createStore只能传入一个,所以就需要将多个reducer合并成一个
// combineReducers 返回值就是合并之后的reducer
const rootReducer = combineReducers({
  zs: reducer,
  self: listReducer,
})
// 2. 创建store对象
const store = createStore(
  rootReducer,
  //   { count: 8 }, // 可以用来初始化redux数据，优先级更高。 但是不常用
  composeWithDevTools(applyMiddleware(thunk))
)
export default store
